package com.example.springbootsfzy.controller.sunnan;

import com.example.springbootsfzy.domain.ConsultantLevels;
import com.example.springbootsfzy.domain.Consultants;
import com.example.springbootsfzy.mapper.ConsultantsMapper;
import com.example.springbootsfzy.service.sunnan.FilterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/filter")
@CrossOrigin
public class FilterController {

    @Autowired
    private FilterService filterService;

    /**
     * 返回所有的extra
     * @return List<String>
     */
    @GetMapping("/extra")
    @ResponseBody
    public List<String> getExtra() {
        return filterService.getExtra();
    }

    /**
     * 返回所有的level
     * @return List<String>
     */
    @GetMapping("/level")
    @ResponseBody
    public List<ConsultantLevels> getLevel() {
        return filterService.getLevel();
    }


    /**
     * 根据筛选条件获取咨询师列表
     * @return 咨询师列表
     */
    @GetMapping("/filter")
    public ResponseEntity<List<Consultants>> findConsultants(
            @RequestParam(required = false) String gender,    // 性别
            @RequestParam(required = false) String area,      // 地区
            @RequestParam(required = false) List<String> fields, // 擅长领域
            @RequestParam(required = false) String level)     // 咨询师等级
    {
        // 调用 Service 层查询咨询师列表
        List<Consultants> consultants = filterService.findConsultantsByFilters(gender, area, fields, level);
        return ResponseEntity.ok(consultants);  // 返回查询结果
    }


}
